package com.thomas.jvm;

import java.util.ArrayList;

/**   
* @Description: TODO(用一句话描述该文件做什么) 
* @author thomas_liu  
* @date 2018年6月6日 下午7:53:24 
* @version V1.0   
*/
public class TestMemory {

	
	static class OOMObject {
		public byte[] placeholder = new byte[64*1024];
		
	}
	
	public static void fillHeap(int num) throws Exception{
		
		ArrayList<OOMObject> list = new ArrayList<OOMObject>();
		for(int i=0;i<num;i++){
			Thread.sleep(50);
			list.add(new OOMObject());
		}
		System.gc();
	}
	
	public static void main(String[] args) throws Exception {
		fillHeap(1000);
		Thread.sleep(500000);
	}
	
}
